function out=tone(digit)
% tone - generates tone for each digit
%        *=10, 0=11 and #=12

FS=8000;
X=0:1/FS:0.2; % time runs for 0.2s
high=[1209 1336 1477]; % high frequencies
low=[697 770 852 941]; % low frequencies
high_index=mod(digit,3);% the high frequency is chosen from the vector using the modulo 3 of the digit
if high_index==0 % unless modulo 3 is zero, then it is supposed to be 3.
    high_index=3;
end
hf=high(high_index); 
hs=sin(2*pi*hf*X);
lf=low(ceil(1/3)); % the low frequency is chosen from the vector by dividing the digit by 3 and rounding up.
ls=sin(2*pi*lf*X);

out=ls+hs;